package com.ruoyi.product.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.product.mapper.TbBrandMapper;
import com.ruoyi.product.domain.TbBrand;
import com.ruoyi.product.service.ITbBrandService;

/**
 * 品牌Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-02
 */
@Service
public class TbBrandServiceImpl implements ITbBrandService 
{
    @Autowired
    private TbBrandMapper tbBrandMapper;

    /**
     * 查询品牌
     * 
     * @param id 品牌主键
     * @return 品牌
     */
    @Override
    public TbBrand selectTbBrandById(Long id)
    {
        return tbBrandMapper.selectTbBrandById(id);
    }

    /**
     * 查询品牌列表
     * 
     * @param tbBrand 品牌
     * @return 品牌
     */
    @Override
    public List<TbBrand> selectTbBrandList(TbBrand tbBrand)
    {
        return tbBrandMapper.selectTbBrandList(tbBrand);
    }

    /**
     * 新增品牌
     * 
     * @param tbBrand 品牌
     * @return 结果
     */
    @Override
    public int insertTbBrand(TbBrand tbBrand)
    {
        tbBrand.setCreateTime(DateUtils.getNowDate());
        return tbBrandMapper.insertTbBrand(tbBrand);
    }

    /**
     * 修改品牌
     * 
     * @param tbBrand 品牌
     * @return 结果
     */
    @Override
    public int updateTbBrand(TbBrand tbBrand)
    {
        tbBrand.setUpdateTime(DateUtils.getNowDate());
        return tbBrandMapper.updateTbBrand(tbBrand);
    }

    /**
     * 批量删除品牌
     * 
     * @param ids 需要删除的品牌主键
     * @return 结果
     */
    @Override
    public int deleteTbBrandByIds(Long[] ids)
    {
        return tbBrandMapper.deleteTbBrandByIds(ids);
    }

    /**
     * 删除品牌信息
     * 
     * @param id 品牌主键
     * @return 结果
     */
    @Override
    public int deleteTbBrandById(Long id)
    {
        return tbBrandMapper.deleteTbBrandById(id);
    }

    @Override
    public AjaxResult getBrandListAll() {
        List<TbBrand> tbBrands = tbBrandMapper.selectTbBrandList(null);
        return AjaxResult.success(tbBrands);


    }
}
